home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / IISEXT.VB_ / iisext.vbs
Encoding:
Text File  |  2003-02-21  |  33.7 KB  |  967 lines

  1. '
  2. ' Copyright (c) Microsoft Corporation.  All rights reserved.
  3. '
  4. ' VBScript Source File
  5. '
  6. ' Script Name: IIsExt.vbs
  7. '
  8.  
  9. Option Explicit
  10. On Error Resume Next
  11.  
  12. ' Error codes
  13. Const ERR_OK              = 0
  14. Const ERR_GENERAL_FAILURE = 1
  15.  
  16. '''''''''''''''''''''
  17. ' Messages
  18. Const L_NotEnoughParams_ErrorMessage   = "Not enough parameters."
  19. Const L_InvalidSwitch_ErrorMessage     = "Invalid switch: %1"
  20. Const L_CmdLib_ErrorMessage            = "Could not create an instance of the CmdLib object."
  21. Const L_ChkCmdLibReg_ErrorMessage      = "Please register the Microsoft.CmdLib component."
  22. Const L_ScriptHelper_ErrorMessage      = "Could not create an instance of the IIsScriptHelper object."
  23. Const L_ChkScpHelperReg_ErrorMessage   = "Please, check if the Microsoft.IIsScriptHelper is registered."
  24. Const L_OnlyOneOper_ErrorMessage       = "Please specify only one operation at a time."
  25. Const L_PassWithoutUser_ErrorMessage   = "Please specify /u switch before using /p."
  26. Const L_WMIConnect_ErrorMessage        = "Could not connect to WMI provider."
  27. Const L_Error_ErrorMessage             = "Error &H%1: %2"
  28. Const L_Admin_ErrorMessage             = "You cannot run this command because you are not an"
  29. Const L_Adminp2_ErrorMessage           = "administrator on the server you are trying to configure."
  30. Const L_GetWebSvcObj_ErrorMessage      = "Could not get web service object"
  31. Const L_EnApp_ErrorMessage             = "Error while configuring application or extension."
  32. Const L_NoApp_ErrorMessage             = "The specified application does not exist in the application"
  33. Const L_NoAppp2_ErrorMessage           = "dependencies list."
  34. Const L_NoDep_ErrorMessage             = "The specified application-extension relationship does not"
  35. Const L_NoDepp2_ErrorMessage           = "exist in the application dependencies list."
  36. Const L_NoExt_ErrorMessage             = "The extension does not exist in the restriction list."
  37. Const L_NoEfi_ErrorMessage             = "The extension file does not exist in the restriction list."
  38.  
  39. Const L_EnDep_ErrorMessage             = "Error while configuring dependency."
  40. Const L_ShowList_ErrorMessage          = "Error while showing list.  Please confirm that the"
  41. Const L_ShowList2_ErrorMessage         = "WebSvcExtRestrictionList and ApplicationDependencies"
  42. Const L_ShowList3_ErrorMessage         = "properties exist and are set on the W3SVC node."
  43. Const L_RmEfi_ErrorMessage             = "Error trying to delete extension.  Make sure it exists"
  44. Const L_RmEfip2_ErrorMessage           = "and is deletable."
  45. Const L_EnAppComplete_Message          = "Enabling application complete."
  46. Const L_AddDpComplete_Message          = "Adding dependency complete."
  47. Const L_RemDpComplete_Message          = "Removing dependency complete."
  48. Const L_EnExtComplete_Message          = "Enabling extension complete."
  49. Const L_DsExtComplete_Message          = "Disabling extension complete."
  50. Const L_DsEFiComplete_Message          = "Disabling extension file complete."
  51. Const L_EnEFiComplete_Message          = "Enabling extension file complete."
  52. Const L_AdEFiComplete_Message          = "Adding extension file complete."
  53. Const L_RmEFiComplete_Message          = "Deleting extension file complete."
  54. Const L_ShowListFile_Message           = "Status / Extension Path"
  55. Const L_ShowListFile2_Message          = "------------------------"
  56. '''''''''''''''''''''
  57. ' Help
  58. Const L_Empty_Text     = ""
  59.  
  60. ' General help messages
  61. Const L_SeeHelp_Message         = "Type IIsExt /? for help."
  62.  
  63. Const L_Help_HELP_General01_Text  = "Description: Manages Web Service Extensions."
  64. Const L_Help_HELP_General02_Text  = "Syntax: IIsExt [/s <server> [/u <username> [/p <password>]]]"
  65. Const L_Help_HELP_General02a_Text = "                   [/ListExt | /ListApp | /AddDep | /DisExt"
  66. Const L_Help_HELP_General03_Text  = "                    /EnExt | /RmDep | /EnApp | /EnFile | /DisFile"
  67. Const L_Help_HELP_General04_Text  = "                    /AddFile | /ListFile | /RmFile] <args>"
  68. Const L_Help_HELP_General05_Text  = "Switches:"
  69. Const L_Help_HELP_General06_Text  = "Value                   Description"
  70. Const L_Help_HELP_General06a_Text = "/s <server>             Connect to machine <server>."
  71. Const L_Help_HELP_General06b_Text = "                        [Default: this system]"
  72. Const L_Help_HELP_General06c_Text = "/u <username>           Connect as <domain>\<username> or"
  73. Const L_Help_HELP_General06d_Text = "                        <username>.  [Default: current user]"
  74. Const L_Help_HELP_General06e_Text = "/p <password>           Password for the <username> user."
  75. Const L_Help_HELP_General07_Text  = "/EnApp <appname>        Enables an application in the"
  76. Const L_Help_HELP_General07a_Text = "                        application dependencies list."
  77. Const L_Help_HELP_General08_Text  = "/ListApp                Lists the applications in the"
  78. Const L_Help_HELP_General08a_Text = "                        application dependencies list."
  79. Const L_Help_HELP_General09_Text  = "/AddDep <appname> <ID> [<ID> ...]" 
  80. Const L_Help_HELP_General09a_Text = "                        Adds a dependency between an"
  81. Const L_Help_HELP_General09b_Text = "                        application in the application"
  82. Const L_Help_HELP_General09c_Text = "                        dependencies list and a Web Service"
  83. Const L_Help_HELP_General09d_Text = "                        Extension ID."
  84. Const L_Help_HELP_General10_Text  = "/RmDep  <appname> <ID> [<ID> ...]"
  85. Const L_Help_HELP_General10a_Text = "                        Removes a dependency between an"
  86. Const L_Help_HELP_General10b_Text = "                        application in the application"
  87. Const L_Help_HELP_General10c_Text = "                        dependencies list and a Web Service"
  88. Const L_Help_HELP_General10d_Text = "                        Extension ID."
  89. Const L_Help_HELP_General11_Text  = "/EnExt <ID>             Enables all files for a Web Service"
  90. Const L_Help_HELP_General11a_Text = "                        Extension with the specified Web"
  91. Const L_Help_HELP_General11b_Text = "                        Service Extension ID."
  92. Const L_Help_HELP_General12_Text  = "/DisExt <ID>            Disables all files for a Web Service"
  93. Const L_Help_HELP_General12a_Text = "                        Extension with the specified Web"
  94. Const L_Help_HELP_General12b_Text = "                        Service Extension ID."
  95. Const L_Help_HELP_General13_Text  = "/ListExt                Lists Web Service Extension IDs for"
  96. Const L_Help_HELP_General13a_Text = "                        all defined Web Service Extensions."
  97. Const L_Help_HELP_General14_Text  = "/EnFile <filename>      Enables a single file in the"
  98. Const L_Help_HELP_General14a_Text = "                        restriction list."
  99. Const L_Help_HELP_General15_Text  = "/DisFile <filename>     Disables a single file in the"
  100. Const L_Help_HELP_General15a_Text = "                        restriction list."
  101. Const L_Help_HELP_General16_Text  = "/ListFile               Lists all the files in the"
  102. Const L_Help_HELP_General16a_Text = "                        restriction list."
  103. Const L_Help_HELP_General17_Text  = "/RmFile <filename>      Removes a file from the restriction"
  104. Const L_Help_HELP_General17a_Text = "                        list if it is deletable."
  105. Const L_Help_HELP_General18_Text  = "/AddFile <args>         Adds a file to the restriction list."
  106. Const L_Help_HELP_General19_Text  = "/AddFile /?             Displays help for the /AddFile flag."
  107.  
  108. Const L_Help_HELP_AddFile01_Text  = "Description: Adds a file to the restriction list."
  109. Const L_Help_HELP_AddFile02_Text  = "Syntax: IIsExt [/s <server> [/u <username> [/p <password>]]]"
  110. Const L_Help_HELP_AddFile02a_Text = "               /AddFile <filepath> <access> <ID> <deleteable>"
  111. Const L_Help_HELP_AddFile03_Text  = "               <ShortDesc>"
  112. Const L_Help_HELP_AddFile07_Text  = "<filepath>              The fully qualified path to the dll"
  113. Const L_Help_HELP_AddFile08_Text  = "                        or exe, including the filename and" 
  114. Const L_Help_HELP_AddFile09_Text  = "                        extension.  Special cases include"
  115. Const L_Help_HELP_AddFile09a_Text = "                        *.dll to enable/disable unlisted"
  116. Const L_Help_HELP_AddFile09b_Text = "                        ISAPI's and *.exe to enable/disable"
  117. Const L_Help_HELP_AddFile09c_Text = "                        unlisted CGI's."
  118. Const L_Help_HELP_AddFile10_Text  = "<access>                Set this to 0 to disable or 1 to"
  119. Const L_Help_HELP_AddFile10a_Text = "                        enable the file after it is added."
  120. Const L_Help_HELP_AddFile11_Text  = "<ID>                    This ID is an arbitrary identifier"
  121. Const L_Help_HELP_AddFile11a_Text = "                        that identifies the Web Service"
  122. Const L_Help_HELP_AddFile11b_Text = "                        Extension the file is associated with."
  123. Const L_Help_HELP_AddFile12_Text  = "                        There can be one or more files for"
  124. Const L_Help_HELP_AddFile12a_Text = "                        each Web Service Extension"
  125. Const L_Help_HELP_AddFile13_Text  = "<deletable>             Set this to 0 to prevent this file"
  126. Const L_Help_HELP_AddFile13a_Text = "                        from being deleted from the restriction" 
  127. Const L_Help_HELP_AddFile14_Text  = "                        list or 1 to allow this file to be"
  128. Const L_Help_HELP_AddFile14a_Text = "                        deleted from the restriction list."
  129. Const L_Help_HELP_AddFile15_Text  = "<ShortDesc>             This is a brief text description of"
  130. Const L_Help_HELP_AddFile15a_Text = "                        the Web Service Extension the file is"
  131. Const L_Help_HELP_AddFile16_Text  = "                        associated with.  Files with the same"
  132. Const L_Help_HELP_AddFile16a_Text = "                        ID should also have the same ShortDesc."
  133.  
  134. ''''''''''''''''''''''''
  135. ' Operation codes
  136. Const OPER_ENAPP = 1
  137. Const OPER_ADDDP = 3
  138. Const OPER_REMDP = 4
  139. Const OPER_ENEXT = 5
  140. Const OPER_DSEXT = 6
  141. Const OPER_ENEFI = 7
  142. Const OPER_DSEFI = 8
  143. Const OPER_ADEFI = 9
  144. Const OPER_RMEFI = 10
  145. Const OPER_LSAPP = 11
  146. Const OPER_LSEXT = 12
  147. Const OPER_LSEFI = 13
  148.  
  149. '
  150. ' Main block
  151. '
  152. Dim oScriptHelper, oCmdLib
  153. Dim intResult, intOperation
  154. Dim strServer, strUser, strPassword
  155. Dim strCmdLineOptions, strAppName
  156. Dim oError, aArgs
  157.  
  158. ' Default values
  159. strServer = "."
  160. strUser = ""
  161. strPassword = ""
  162. intOperation = 0
  163.  
  164. ' Instantiate the CmdLib for output string formatting
  165. Set oCmdLib = CreateObject("Microsoft.CmdLib")
  166. If Err.Number <> 0 Then
  167.     WScript.Echo L_CmdLib_ErrorMessage
  168.     WScript.Echo L_ChkCmdLibReg_ErrorMessage    
  169.     WScript.Quit(ERR_GENERAL_FAILURE)
  170. End If
  171. Set oCmdLib.ScriptingHost = WScript.Application
  172.  
  173. ' Instantiate script helper object
  174. Set oScriptHelper = CreateObject("Microsoft.IIsScriptHelper")
  175. If Err.Number <> 0 Then
  176.     WScript.Echo L_ScriptHelper_ErrorMessage
  177.     WScript.Echo L_ChkScpHelperReg_ErrorMessage    
  178.     WScript.Quit(ERR_GENERAL_FAILURE)
  179. End If
  180.  
  181. Set oScriptHelper.ScriptHost = WScript
  182.  
  183. ' Check if we are being run with cscript.exe instead of wscript.exe
  184. oScriptHelper.CheckScriptEngine
  185.  
  186. ' Command Line parsing
  187. Dim argObj, arg
  188. Set argObj = WScript.Arguments
  189.  
  190. strCmdLineOptions = "[server:s:1;user:u:1;password:p:1];enapp::1;listapp::0;adddep::n;" &_
  191.                     "rmdep::n;enext::1;disext::n;listext::0;enfile::1;disfile::1;addfile::5;" &_
  192.                     "rmfile::1;listfile::0"
  193.  
  194. Set oError = oScriptHelper.ParseCmdLineOptions(strCmdLineOptions)
  195.  
  196. If Not oError Is Nothing Then
  197.     If oError.ErrorCode = oScriptHelper.ERROR_NOT_ENOUGH_ARGS Then
  198.         ' Not enough arguments for a specified switch
  199.         WScript.Echo L_NotEnoughParams_ErrorMessage
  200.         WScript.Echo L_SeeHelp_Message
  201.     Else
  202.         ' Invalid switch
  203.         oCmdLib.vbPrintf L_InvalidSwitch_ErrorMessage, Array(oError.SwitchName)
  204.           WScript.Echo L_SeeHelp_Message
  205.     End If
  206.     
  207.         WScript.Quit(ERR_GENERAL_FAILURE)
  208. End If
  209.  
  210. If oScriptHelper.GlobalHelpRequested Then
  211.     DisplayHelpMessage
  212.     WScript.Quit(ERR_OK)
  213. End If
  214.  
  215. For Each arg In oScriptHelper.Switches
  216.     Select Case arg
  217.  
  218.     Case "server"
  219.         ' Server information
  220.         strServer = oScriptHelper.GetSwitch(arg)
  221.  
  222.     Case "user"
  223.         ' User information
  224.         strUser = oScriptHelper.GetSwitch(arg)
  225.  
  226.     Case "password"
  227.         ' Password information
  228.         strPassword = oScriptHelper.GetSwitch(arg)
  229.  
  230.     Case "enapp"
  231.         If (intOperation <> 0) Then
  232.             WScript.Echo L_OnlyOneOper_ErrorMessage
  233.             WScript.Echo L_SeeHelp_Message
  234.             WScript.Quit(ERR_GENERAL_FAILURE)
  235.         End If
  236.  
  237.         intOperation = OPER_ENAPP
  238.  
  239.         If oScriptHelper.IsHelpRequested(arg) Then
  240.             ' display enapp specific help
  241.         End If
  242.  
  243.         strAppName = oScriptHelper.GetSwitch(arg)
  244.  
  245.     Case "adddep"
  246.         If (intOperation <> 0) Then
  247.             WScript.Echo L_OnlyOneOper_ErrorMessage
  248.             WScript.Echo L_SeeHelp_Message
  249.             WScript.Quit(ERR_GENERAL_FAILURE)
  250.         End If
  251.  
  252.         intOperation = OPER_ADDDP
  253.  
  254.         If oScriptHelper.IsHelpRequested(arg) Then
  255.             ' display enapp specific help
  256.         End If
  257.  
  258.         aArgs = oScriptHelper.GetSwitch(arg)
  259.  
  260.         If UBound(aArgs) = -1 Then
  261.             WScript.Echo L_NotEnoughParams_ErrorMessage
  262.             WScript.Echo L_SeeHelp_Message
  263.             WScript.Quit(ERR_GENERAL_FAILURE)
  264.         End If
  265.  
  266.     Case "rmdep"
  267.         If (intOperation <> 0) Then
  268.             WScript.Echo L_OnlyOneOper_ErrorMessage
  269.             WScript.Echo L_SeeHelp_Message
  270.             WScript.Quit(ERR_GENERAL_FAILURE)
  271.         End If
  272.  
  273.         intOperation = OPER_REMDP
  274.  
  275.         If oScriptHelper.IsHelpRequested(arg) Then
  276.             ' display enapp specific help
  277.         End If
  278.  
  279.         aArgs = oScriptHelper.GetSwitch(arg)
  280.  
  281.         If UBound(aArgs) = -1 Then
  282.             WScript.Echo L_NotEnoughParams_ErrorMessage
  283.             WScript.Echo L_SeeHelp_Message
  284.             WScript.Quit(ERR_GENERAL_FAILURE)
  285.         End If
  286.  
  287.     Case "enext"
  288.         If (intOperation <> 0) Then
  289.             WScript.Echo L_OnlyOneOper_ErrorMessage
  290.             WScript.Echo L_SeeHelp_Message
  291.             WScript.Quit(ERR_GENERAL_FAILURE)
  292.         End If
  293.  
  294.         intOperation = OPER_ENEXT
  295.  
  296.         If oScriptHelper.IsHelpRequested(arg) Then
  297.             ' display enapp specific help
  298.         End If
  299.  
  300.         strAppName = oScriptHelper.GetSwitch(arg)
  301.  
  302.     Case "disfile"
  303.         If (intOperation <> 0) Then
  304.             WScript.Echo L_OnlyOneOper_ErrorMessage
  305.             WScript.Echo L_SeeHelp_Message
  306.             WScript.Quit(ERR_GENERAL_FAILURE)
  307.         End If
  308.  
  309.         intOperation = OPER_DSEFI
  310.  
  311.         If oScriptHelper.IsHelpRequested(arg) Then
  312.             ' display enapp specific help
  313.         End If
  314.  
  315.         strAppName = oScriptHelper.GetSwitch(arg)
  316.  
  317.     Case "enfile"
  318.         If (intOperation <> 0) Then
  319.             WScript.Echo L_OnlyOneOper_ErrorMessage
  320.             WScript.Echo L_SeeHelp_Message
  321.             WScript.Quit(ERR_GENERAL_FAILURE)
  322.         End If
  323.  
  324.         intOperation = OPER_ENEFI
  325.  
  326.         If oScriptHelper.IsHelpRequested(arg) Then
  327.             ' display enapp specific help
  328.         End If
  329.  
  330.         strAppName = oScriptHelper.GetSwitch(arg)
  331.  
  332.     Case "disext"
  333.         If (intOperation <> 0) Then
  334.             WScript.Echo L_OnlyOneOper_ErrorMessage
  335.             WScript.Echo L_SeeHelp_Message
  336.             WScript.Quit(ERR_GENERAL_FAILURE)
  337.         End If
  338.  
  339.         intOperation = OPER_DSEXT
  340.  
  341.         If oScriptHelper.IsHelpRequested(arg) Then
  342.             ' display enapp specific help
  343.         End If
  344.  
  345.         aArgs = oScriptHelper.GetSwitch(arg)
  346.  
  347.     Case "addfile"
  348.         If (intOperation <> 0) Then
  349.             WScript.Echo L_OnlyOneOper_ErrorMessage
  350.             WScript.Echo L_SeeHelp_Message
  351.             WScript.Quit(ERR_GENERAL_FAILURE)
  352.         End If
  353.  
  354.         intOperation = OPER_ADEFI
  355.  
  356.         If oScriptHelper.IsHelpRequested(arg) Then
  357.             ' display addfile specific help
  358.             DisplayAddFileHelp
  359.             WScript.Quit(ERR_OK)
  360.         End If
  361.  
  362.         aArgs = oScriptHelper.GetSwitch(arg)
  363.  
  364.     Case "rmfile"
  365.         If (intOperation <> 0) Then
  366.             WScript.Echo L_OnlyOneOper_ErrorMessage
  367.             WScript.Echo L_SeeHelp_Message
  368.             WScript.Quit(ERR_GENERAL_FAILURE)
  369.         End If
  370.  
  371.         intOperation = OPER_RMEFI
  372.  
  373.         If oScriptHelper.IsHelpRequested(arg) Then
  374.             ' display enapp specific help
  375.         End If
  376.  
  377.         strAppName = oScriptHelper.GetSwitch(arg)
  378.  
  379.     Case "listapp"
  380.         If (intOperation <> 0) Then
  381.             WScript.Echo L_OnlyOneOper_ErrorMessage
  382.             WScript.Echo L_SeeHelp_Message
  383.             WScript.Quit(ERR_GENERAL_FAILURE)
  384.         End If
  385.  
  386.         intOperation = OPER_LSAPP
  387.  
  388.         If oScriptHelper.IsHelpRequested(arg) Then
  389.             ' display enapp specific help
  390.         End If
  391.  
  392.     Case "listext"
  393.         If (intOperation <> 0) Then
  394.             WScript.Echo L_OnlyOneOper_ErrorMessage
  395.             WScript.Echo L_SeeHelp_Message
  396.             WScript.Quit(ERR_GENERAL_FAILURE)
  397.         End If
  398.  
  399.         intOperation = OPER_LSEXT
  400.  
  401.         If oScriptHelper.IsHelpRequested(arg) Then
  402.             ' display enapp specific help
  403.         End If
  404.  
  405.     Case "listfile"
  406.         If (intOperation <> 0) Then
  407.             WScript.Echo L_OnlyOneOper_ErrorMessage
  408.             WScript.Echo L_SeeHelp_Message
  409.             WScript.Quit(ERR_GENERAL_FAILURE)
  410.         End If
  411.  
  412.         intOperation = OPER_LSEFI
  413.  
  414.         If oScriptHelper.IsHelpRequested(arg) Then
  415.             ' display enapp specific help
  416.         End If
  417.  
  418.     End Select
  419. Next
  420.  
  421. ' Check Parameters
  422. If intOperation = 0 Then
  423.     WScript.Echo L_SeeHelp_Message
  424.     WScript.Quit(ERR_GENERAL_FAILURE)
  425. End If
  426.  
  427. ' Check if /p is specified but /u isn't. In this case, we should bail out with an error
  428. If oScriptHelper.Switches.Exists("password") And Not oScriptHelper.Switches.Exists("user") Then
  429.     WScript.Echo L_PassWithoutUser_ErrorMessage
  430.     WScript.Quit(ERR_GENERAL_FAILURE)
  431. End If
  432.  
  433. ' Check if /u is specified but /p isn't. In this case, we should ask for a password
  434. If oScriptHelper.Switches.Exists("user") And Not oScriptHelper.Switches.Exists("password") Then
  435.     strPassword = oCmdLib.GetPassword
  436. End If
  437.  
  438. ' Initializes authentication with remote machine
  439. intResult = oScriptHelper.InitAuthentication(strServer, strUser, strPassword)
  440. If intResult <> 0 Then
  441.     WScript.Quit(intResult)
  442. End If
  443.  
  444. ' Choose operation
  445. Select Case intOperation
  446.     Case OPER_ENAPP
  447.         intResult = ChApp(strAppName, intOperation)
  448.         If intResult=0 Then
  449.             WScript.Echo(L_EnAppComplete_Message)
  450.         End If
  451.  
  452.     Case OPER_ADDDP
  453.         intResult = ChDep(aArgs, intOperation)
  454.         If intResult=0 Then
  455.             WScript.Echo(L_AddDpComplete_Message)
  456.         End If
  457.  
  458.     Case OPER_REMDP
  459.         intResult = ChDep(aArgs, intOperation)
  460.         If intResult=0 Then
  461.             WScript.Echo(L_RemDpComplete_Message)
  462.         End If
  463.  
  464.     Case OPER_ENEXT
  465.         intResult = ChApp(strAppName, intOperation)
  466.         If intResult=0 Then
  467.             WScript.Echo(L_EnExtComplete_Message)
  468.         End If
  469.  
  470.     Case OPER_ENEFI
  471.         intResult = ChApp(strAppName, intOperation)
  472.         If intResult=0 Then
  473.             WScript.Echo(L_EnEfiComplete_Message)
  474.         End If
  475.  
  476.     Case OPER_DSEFI
  477.         intResult = ChApp(strAppName, intOperation)
  478.         If intResult=0 Then
  479.             WScript.Echo(L_DsEfiComplete_Message)
  480.         End If
  481.  
  482.     Case OPER_DSEXT
  483.         intResult = DsExt(aArgs)
  484.         If intResult=0 Then
  485.             WScript.Echo(L_DsExtComplete_Message)
  486.         End If
  487.  
  488.     Case OPER_ADEFI
  489.         intResult = ChDep(aArgs, intOperation)
  490.         If intResult=0 Then
  491.             WScript.Echo(L_AdEFiComplete_Message)
  492.         End If
  493.  
  494.     Case OPER_RMEFI
  495.         intResult = RmEfi(strAppName)
  496.         If intResult=0 Then
  497.             WScript.Echo(L_RmEFiComplete_Message)
  498.         End If
  499.  
  500.     Case OPER_LSAPP
  501.         intResult = ShowList(intOperation)
  502.     
  503.     Case OPER_LSEXT
  504.         intResult = ShowList(intOperation)
  505.     
  506.     Case OPER_LSEFI
  507.         intResult = ShowListFile()
  508.  
  509. End Select
  510.  
  511. ' Return value to command processor
  512. WScript.Quit(intResult)
  513.  
  514. '''''''''''''''''''''''''
  515. ' End Of Main Block
  516. '''''''''''''''''''''
  517.  
  518. '''''''''''''''''''''''''''
  519. ' DisplayHelpMessage
  520. '''''''''''''''''''''''''''
  521. Sub DisplayHelpMessage()
  522.     WScript.Echo L_Help_HELP_General01_Text
  523.     WScript.Echo L_Empty_Text
  524.     WScript.Echo L_Help_HELP_General02_Text
  525.     WScript.Echo L_Help_HELP_General02a_Text
  526.     WScript.Echo L_Help_HELP_General03_Text
  527.     WScript.Echo L_Help_HELP_General04_Text
  528.     WScript.Echo L_Empty_Text
  529.     WScript.Echo L_Help_HELP_General05_Text
  530.     WScript.Echo L_Empty_Text
  531.     WScript.Echo L_Help_HELP_General06_Text
  532.     WScript.Echo L_Help_HELP_General06a_Text
  533.     WScript.Echo L_Help_HELP_General06b_Text
  534.     WScript.Echo L_Help_HELP_General06c_Text
  535.     WScript.Echo L_Help_HELP_General06d_Text
  536.     WScript.Echo L_Help_HELP_General06e_Text
  537.     WScript.Echo L_Help_HELP_General07_Text
  538.     WScript.Echo L_Help_HELP_General07a_Text
  539.     WScript.Echo L_Help_HELP_General08_Text
  540.     WScript.Echo L_Help_HELP_General08a_Text
  541.     WScript.Echo L_Help_HELP_General09_Text
  542.     WScript.Echo L_Help_HELP_General09a_Text
  543.     WScript.Echo L_Help_HELP_General09b_Text
  544.     WScript.Echo L_Help_HELP_General09c_Text
  545.     WScript.Echo L_Help_HELP_General09d_Text
  546.     WScript.Echo L_Help_HELP_General10_Text
  547.     WScript.Echo L_Help_HELP_General10a_Text
  548.     WScript.Echo L_Help_HELP_General10b_Text
  549.     WScript.Echo L_Help_HELP_General10c_Text
  550.     WScript.Echo L_Help_HELP_General10d_Text
  551.     WScript.Echo L_Help_HELP_General11_Text
  552.     WScript.Echo L_Help_HELP_General11a_Text
  553.     WScript.Echo L_Help_HELP_General11b_Text
  554.     WScript.Echo L_Help_HELP_General12_Text
  555.     WScript.Echo L_Help_HELP_General12a_Text
  556.     WScript.Echo L_Help_HELP_General12b_Text
  557.     WScript.Echo L_Help_HELP_General13_Text
  558.     WScript.Echo L_Help_HELP_General13a_Text
  559.     WScript.Echo L_Help_HELP_General14_Text
  560.     WScript.Echo L_Help_HELP_General14a_Text
  561.     WScript.Echo L_Help_HELP_General15_Text
  562.     WScript.Echo L_Help_HELP_General15a_Text
  563.     WScript.Echo L_Help_HELP_General16_Text
  564.     WScript.Echo L_Help_HELP_General16a_Text
  565.     WScript.Echo L_Help_HELP_General17_Text
  566.     WScript.Echo L_Help_HELP_General17a_Text
  567.     WScript.Echo L_Help_HELP_General18_Text
  568.     WScript.Echo L_Help_HELP_General19_Text
  569. End Sub
  570.  
  571. '''''''''''''''''''''''''''
  572. ' DisplayHelpMessage
  573. '''''''''''''''''''''''''''
  574. Sub DisplayAddFileHelp()
  575.     WScript.Echo L_Help_HELP_AddFile01_Text
  576.     WScript.Echo L_Empty_Text
  577.     WScript.Echo L_Help_HELP_AddFile02_Text
  578.     WScript.Echo L_Help_HELP_AddFile02a_Text
  579.     WScript.Echo L_Help_HELP_AddFile03_Text
  580.     WScript.Echo L_Empty_Text
  581.     WScript.Echo L_Help_HELP_General05_Text
  582.     WScript.Echo L_Empty_Text
  583.     WScript.Echo L_Help_HELP_General06_Text
  584.     WScript.Echo L_Help_HELP_General06a_Text
  585.     WScript.Echo L_Help_HELP_General06b_Text
  586.     WScript.Echo L_Help_HELP_General06c_Text
  587.     WScript.Echo L_Help_HELP_General06d_Text
  588.     WScript.Echo L_Help_HELP_General06e_Text
  589.     WScript.Echo L_Help_HELP_AddFile07_Text
  590.     WScript.Echo L_Help_HELP_AddFile08_Text
  591.     WScript.Echo L_Help_HELP_AddFile09_Text
  592.     WScript.Echo L_Help_HELP_AddFile09a_Text
  593.     WScript.Echo L_Help_HELP_AddFile09b_Text
  594.     WScript.Echo L_Help_HELP_AddFile09c_Text
  595.     WScript.Echo L_Help_HELP_AddFile10_Text
  596.     WScript.Echo L_Help_HELP_AddFile10a_Text
  597.     WScript.Echo L_Help_HELP_AddFile11_Text
  598.     WScript.Echo L_Help_HELP_AddFile11a_Text
  599.     WScript.Echo L_Help_HELP_AddFile11b_Text
  600.     WScript.Echo L_Help_HELP_AddFile12_Text
  601.     WScript.Echo L_Help_HELP_AddFile12a_Text
  602.     WScript.Echo L_Help_HELP_AddFile13_Text
  603.     WScript.Echo L_Help_HELP_AddFile13a_Text
  604.     WScript.Echo L_Help_HELP_AddFile14_Text
  605.     WScript.Echo L_Help_HELP_AddFile14a_Text
  606.     WScript.Echo L_Help_HELP_AddFile15_Text
  607.     WScript.Echo L_Help_HELP_AddFile15a_Text
  608.     WScript.Echo L_Help_HELP_AddFile16_Text
  609.     WScript.Echo L_Help_HELP_AddFile16a_Text
  610. End Sub
  611.  
  612. Function ChApp(strAppName, intOperation)
  613.     Dim WebSvcObj
  614.     
  615.     On Error Resume Next
  616.  
  617.     oScriptHelper.WMIConnect
  618.     If Err.Number Then
  619.         WScript.Echo L_WMIConnect_ErrorMessage
  620.         oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  621.         ChApp = Err.Number
  622.         Exit Function
  623.     End If
  624.  
  625.     Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebService='w3svc'")
  626.     If Err.Number Then
  627.         Select Case Err.Number
  628.             Case &H80070005
  629.                 WScript.Echo L_Admin_ErrorMessage
  630.                 WScript.Echo L_Adminp2_ErrorMessage
  631.  
  632.             Case Else
  633.                 WScript.Echo L_GetWebSvcObj_ErrorMessage
  634.                 oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  635.         End Select
  636.  
  637.         ChApp = Err.Number
  638.         Exit Function
  639.     End If
  640.     
  641.     Select Case intOperation
  642.         Case OPER_ENAPP
  643.             WebSvcObj.EnableApplication strAppName
  644.  
  645.         Case OPER_ENEXT
  646.             WebSvcObj.EnableWebServiceExtension strAppName
  647.  
  648.         Case OPER_ENEFI
  649.             WebSvcObj.EnableExtensionFile strAppName
  650.  
  651.         Case OPER_DSEFI
  652.             WebSvcObj.DisableExtensionFile strAppName
  653.  
  654.     End Select
  655.  
  656.     If Err.Number Then
  657.         WScript.Echo L_EnApp_ErrorMessage
  658.         WScript.Echo Err.Description
  659.         
  660.         Select Case intOperation
  661.             Case OPER_ENAPP
  662.                 WScript.Echo L_NoApp_ErrorMessage
  663.                 WScript.Echo L_NoAppp2_ErrorMessage
  664.  
  665.             Case OPER_ENEXT
  666.                 WScript.Echo L_NoExt_ErrorMessage
  667.  
  668.             Case OPER_ENEFI
  669.                 WScript.Echo L_NoEfi_ErrorMessage
  670.      
  671.             Case OPER_DSEFI
  672.                 WScript.Echo L_NoEfi_ErrorMessage
  673.         End Select
  674.  
  675.         ChApp = Err.Number
  676.         Exit Function
  677.     End If
  678.     
  679. End Function
  680.  
  681. Function RmEfi(strAppName)
  682.     Dim WebSvcObj, extObj, restrictions, i, bDel
  683.     
  684.     bDel = False
  685.  
  686.     On Error Resume Next
  687.  
  688.     oScriptHelper.WMIConnect
  689.     If Err.Number Then
  690.         WScript.Echo L_WMIConnect_ErrorMessage
  691.         oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  692.         RmEfi = Err.Number
  693.         Exit Function
  694.     End If
  695.  
  696.     Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebService='w3svc'")
  697.     If Err.Number Then
  698.         Select Case Err.Number
  699.             Case &H80070005
  700.                 WScript.Echo L_Admin_ErrorMessage
  701.                 WScript.Echo L_Adminp2_ErrorMessage
  702.  
  703.             Case Else
  704.                 WScript.Echo L_GetWebSvcObj_ErrorMessage
  705.                 oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  706.         End Select
  707.  
  708.         RmEfi = Err.Number
  709.         Exit Function
  710.     End If
  711.     
  712.     Set extObj = oScriptHelper.ProviderObj.get("IIsWebServiceSetting='w3svc'")
  713.     restrictions = extObj.WebSvcExtRestrictionList
  714.  
  715.     For i=0 to UBOUND(restrictions)
  716.         If UCASE(restrictions(i).FilePath) = UCASE(strAppName) Then
  717.             If restrictions(i).Deletable = 1 Then
  718.                 WebSvcObj.DeleteExtensionFileRecord strAppName
  719.                 bDel = True
  720.             End If
  721.         End If
  722.     Next
  723.  
  724.     If Err.Number Then
  725.         WScript.Echo L_EnApp_ErrorMessage
  726.         WScript.Echo Err.Description
  727.         
  728.         RmEfi = Err.Number
  729.         Exit Function
  730.     End If
  731.     
  732.     If bDel = False Then
  733.         WScript.Echo L_RmEfi_ErrorMessage
  734.         WScript.Echo L_RmEfip2_ErrorMessage
  735.         RmEfi = 1
  736.     End If
  737. End Function
  738.  
  739. Function ChDep(aArgs, intOperation)
  740.     Dim WebSvcObj, i
  741.     
  742.     On Error Resume Next
  743.  
  744.     oScriptHelper.WMIConnect
  745.     If Err.Number Then
  746.         WScript.Echo L_WMIConnect_ErrorMessage
  747.         oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  748.         ChDep = Err.Number
  749.         Exit Function
  750.     End If
  751.  
  752.     Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebService='w3svc'")
  753.     If Err.Number Then
  754.         Select Case Err.Number
  755.             Case &H80070005
  756.                 WScript.Echo L_Admin_ErrorMessage
  757.                 WScript.Echo L_Adminp2_ErrorMessage
  758.  
  759.             Case Else
  760.                 WScript.Echo L_GetWebSvcObj_ErrorMessage
  761.                 oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  762.         End Select
  763.  
  764.         ChDep = Err.Number
  765.         Exit Function
  766.     End If
  767.     
  768.     If OPER_ADEFI = intOperation Then
  769.         If ((aArgs(1) <> 0) And (aArgs(1) <> 1)) Then
  770.             aArgs(1) = 0
  771.         End If
  772.  
  773.         WebSvcObj.AddExtensionFile aArgs(0), aArgs(1), aArgs(2), aArgs(3), aArgs(4)
  774.     Else
  775.  
  776.         If UBOUND(aArgs) < 1 Then
  777.             WScript.Echo L_NotEnoughParams_ErrorMessage
  778.             WScript.Echo L_SeeHelp_Message
  779.             ChDep = ERR_GENERAL_FAILURE
  780.             Exit Function
  781.         End If
  782.  
  783.         For i=1 to UBOUND(aArgs)
  784.      
  785.             Select Case intOperation
  786.                 Case OPER_ADDDP
  787.                     WebSvcObj.AddDependency aArgs(0), aArgs(i)
  788.  
  789.                 Case OPER_REMDP
  790.                     WebSvcObj.RemoveDependency aArgs(0), aArgs(i)
  791.             End Select
  792.  
  793.             If Err.Number Then
  794.                 WScript.Echo L_EnDep_ErrorMessage
  795.                 WScript.Echo Err.Description
  796.                 WScript.Echo L_NoDep_ErrorMessage
  797.                 WScript.Echo L_NoDepp2_ErrorMessage
  798.  
  799.                 ChDep = Err.Number
  800.                 Exit Function
  801.             End If
  802.         Next
  803.     
  804.     End If
  805.  
  806.     If Err.Number Then
  807.         WScript.Echo L_EnApp_ErrorMessage
  808.         WScript.Echo Err.Description
  809.         
  810.         ChDep = Err.Number
  811.         Exit Function
  812.     End If
  813.  
  814. End Function
  815.  
  816. Function DsExt(aArgs)
  817.     Dim WebSvcObj, i
  818.     
  819.     On Error Resume Next
  820.  
  821.     oScriptHelper.WMIConnect
  822.     If Err.Number Then
  823.         WScript.Echo L_WMIConnect_ErrorMessage
  824.         oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  825.         DsExt = Err.Number
  826.         Exit Function
  827.     End If
  828.  
  829.     Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebService='w3svc'")
  830.     If Err.Number Then
  831.         Select Case Err.Number
  832.             Case &H80070005
  833.                 WScript.Echo L_Admin_ErrorMessage
  834.                 WScript.Echo L_Adminp2_ErrorMessage
  835.  
  836.             Case Else
  837.                 WScript.Echo L_GetWebSvcObj_ErrorMessage
  838.                 oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  839.         End Select
  840.  
  841.         DsExt = Err.Number
  842.         Exit Function
  843.     End If
  844.     
  845.     For i=0 to UBOUND(aArgs)
  846.  
  847.         WebSvcObj.DisableWebServiceExtension aArgs(i)
  848.  
  849.         If Err.Number Then
  850.             WScript.Echo L_EnApp_ErrorMessage
  851.             WScript.Echo Err.Description
  852.             WScript.Echo L_NoExt_ErrorMessage
  853.  
  854.             DsExt = Err.Number
  855.             Exit Function
  856.         End If
  857.     Next
  858.     
  859. End Function
  860.  
  861. Function ShowList(intOperation)
  862.     Dim WebSvcObj, holder, i, mylist
  863.     
  864.     On Error Resume Next
  865.  
  866.     oScriptHelper.WMIConnect
  867.     If Err.Number Then
  868.         WScript.Echo L_WMIConnect_ErrorMessage
  869.         oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  870.         ShowList = Err.Number
  871.         Exit Function
  872.     End If
  873.  
  874.     Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebService='w3svc'")
  875.     If Err.Number Then
  876.         Select Case Err.Number
  877.             Case &H80070005
  878.                 WScript.Echo L_Admin_ErrorMessage
  879.                 WScript.Echo L_Adminp2_ErrorMessage
  880.  
  881.             Case Else
  882.                 WScript.Echo L_GetWebSvcObj_ErrorMessage
  883.                 oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  884.         End Select
  885.  
  886.         ShowList = Err.Number
  887.         Exit Function
  888.     End If
  889.     
  890.     Select Case intOperation
  891.         Case OPER_LSAPP
  892.             set holder=oScriptHelper.ProviderObj.execmethod("IIsWebService='w3svc'", "ListApplications")
  893.             mylist = holder.Applications
  894.  
  895.         Case OPER_LSEXT
  896.             set holder=oScriptHelper.ProviderObj.execmethod("IIsWebService='w3svc'", "ListWebServiceExtensions")
  897.             mylist = holder.Extensions
  898.  
  899.     End Select
  900.  
  901.     If Err.Number Then
  902.         WScript.Echo L_ShowList_ErrorMessage
  903.         WScript.Echo L_ShowList2_ErrorMessage
  904.         WScript.Echo L_ShowList3_ErrorMessage
  905.         WScript.Echo Err.Description
  906.     
  907.         ShowList = Err.Number
  908.         Exit Function
  909.     End If
  910.     
  911.     For i = 0 to UBOUND(mylist)
  912.         WScript.Echo mylist(i) 
  913.     Next
  914.  
  915. End Function
  916.  
  917. Function ShowListFile()
  918.     Dim WebSvcObj, fileList, i
  919.     
  920.     On Error Resume Next
  921.  
  922.     oScriptHelper.WMIConnect
  923.     If Err.Number Then
  924.         WScript.Echo L_WMIConnect_ErrorMessage
  925.         oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  926.         ShowList = Err.Number
  927.         Exit Function
  928.     End If
  929.  
  930.     Set WebSvcObj = oScriptHelper.ProviderObj.get("IIsWebServiceSetting='w3svc'")
  931.     If Err.Number Then
  932.         Select Case Err.Number
  933.             Case &H80070005
  934.                 WScript.Echo L_Admin_ErrorMessage
  935.                 WScript.Echo L_Adminp2_ErrorMessage
  936.  
  937.             Case Else
  938.                 WScript.Echo L_GetWebSvcObj_ErrorMessage
  939.                 oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
  940.         End Select
  941.  
  942.         ShowList = Err.Number
  943.         Exit Function
  944.     End If
  945.     
  946.     fileList = WebSvcObj.WebSvcExtRestrictionList
  947.  
  948.     
  949.     If Err.Number Then
  950.         WScript.Echo L_ShowList_ErrorMessage
  951.         WScript.Echo L_ShowList2_ErrorMessage
  952.         WScript.Echo L_ShowList3_ErrorMessage
  953.         WScript.Echo Err.Description
  954.     
  955.         ShowList = Err.Number
  956.         Exit Function
  957.     End If
  958.     
  959.     WScript.Echo L_Empty_Text
  960.     WScript.Echo L_ShowListFile_Message
  961.     WScript.Echo L_ShowListFile2_Message
  962.  
  963.     For i = 0 to UBOUND(fileList)
  964.         WScript.Echo fileList(i).Access & "  " & fileList(i).FilePath 
  965.     Next
  966. End Function
  967.